Add a vehicle-crop fallback so plates in wide / high-resolution scenes still read#26
Open
chsbusch-dot wants to merge 2 commits into
Open
Add a vehicle-crop fallback so plates in wide / high-resolution scenes still read#26chsbusch-dot wants to merge 2 commits into
chsbusch-dot wants to merge 2 commits into
Conversation
Each full-frame miss fans out to max_vehicle_crops x 2 plate-detection passes; 3 covers the common case (a car or two in view) while keeping worst-case latency and GPU load bounded on busy scenes / small GPUs. Raise it if a scene routinely has more vehicles that need reading. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The plate detector runs at YOLO
size=640, so the whole frame is resized to 640px wide before detection. On wide-angle or high-resolution (e.g. 4K) cameras a license plate is a small part of the scene and, after that resize, can shrink to ~10px — too small to detect — even though it is perfectly legible in the source image. The module then returns "No plates found" on cameras that clearly show plates.Example: a ~60px-wide plate in a 3840×2160 frame becomes ~10px after the 640 resize. (Commonly hit when Blue Iris / Frigate / Agent-DVR send full-resolution frames, but this is a general high-resolution-scene issue, not vendor-specific.)
Fix
Two-pass detection in
ALPR.py:Because a crop is a small region of the original image, the plate keeps its pixels through the 640 resize and detects normally. Well-presented full-frame plates still take the original fast path — the fallback only runs on a miss.
Tuning (constants near the top of
ALPR.py)vehicle_confidence(0.25) — minimum confidence to treat a detection as a vehiclemax_vehicle_crops(8) — cap on vehicles cropped per frame (bounds worst-case latency)vehicle_labels— object classes to cropCost
A miss adds one object-detection pass plus up to
max_vehicle_crops× 2 plate passes, so a fallback read is slower than a direct hit (~1s vs ~150ms on our hardware). Direct hits are unaffected.Testing
python3 -m py_compile ALPR.py,git diff --check